package com.kischang.blog.service;

import com.kischang.blog.dao.ReplyDao;
import com.kischang.blog.model.Reply;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Component
public class ReplyService {
	@Autowired
	private ReplyDao dao;
	@Resource
	private SessionFactory sessionFactory;
	
	@Transactional
	public void save(Reply reply){
		sessionFactory.getCurrentSession().save(reply);
	}

	@Transactional(readOnly=true)
	public Reply getReplyById(int rid) {
		return (Reply) sessionFactory.getCurrentSession().get(Reply.class, rid);
	}
}
